package org.sy.lab.多线程基础._2_同步._2_ReentrantLock._4_使用条件;

public class Bartender implements Runnable {
	
	private Bar bar;
	private Counter counter;
	
	public Bartender(Bar bar, Counter counter) {
		this.bar = bar;
		this.counter = counter;
	}

	@Override
	public void run() {
		while (bar.hasBeer()) {
			bar.getBeer();
			counter.setBeer();
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		counter.setOpen(false);
	}
}
